from merge import det_all
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/api/ocr/recognize', methods=['POST'])
def send_res_json():
    if not request.is_json:
        return jsonify({"error": "Request must be JSON"}), 400
    
    try:
        img_base64 = request.get_json().get('img_base64')

        det_data = det_all(img_base64)
        return det_data, 200
        
    except Exception as e:
        return jsonify({
            "status": "error",
            "message": str(e)
        }), 500

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5000, debug=False)
